export default function(element, target){
  // html只有一个div，并且有设置position
  const ele = document.querySelector(element);
  console.log(ele)
  ele.addEventListener("mousedown", e => {
  // 记录首次位置，也是为了存放上次位置
    let x0 = e.clientX;
    let y0 = e.clientY;
    const handleMove = ({ clientX, clientY, target }) => {
    // 本次位置和上次位置的变化量
    console.log(ele,clientX)
    console.log(getStyle(ele, target))
      ele.style.right = `${parseFloat(ele.style.right, 10) + clientX - x0}px`;
      // ele.style.top = `${parseFloat(ele.style.top, 10) + clientY - y0}px`;
        // 上次位置更新
      x0 = clientX;
      // y0 = clientY;
    };
    ele.addEventListener("mousemove", handleMove);
    ele.addEventListener("mouseup", () => {
      ele.removeEventListener("mousemove", handleMove);
    });
  });

}
function getStyle(obj, name){
  if(obj.currentStyle){
    return obj.currentStyle[name]
  } else {
    return getComputedStyle(obj, null)[name]
  }
}